#!/bin/bash -
#=======================================================================
#
#          FILE: random_file.sh
#         USAGE: ./random_file.sh <file> <size-in-MB>
#   DESCRIPTION: Create a file with random content for specifc size
#  REQUIREMENTS: dd, /dev/urandom
#          BUGS: N/A
#         NOTES: N/A
#        AUTHOR: Ali Ayoub
#         EMAIL: ali@mellanox.com
#       COMPANY: N/A
#       CREATED: 09.17.2010-16:01:22
#      REVISION: 1.0
#=======================================================================

USAGE="Usage: $0 <file> <size in MB>"
EXAMPLE="Example: $0 /tmp/rand.10M 10"
if [ $# != 2 ]; then
        echo $USAGE
        echo $EXAMPLE
        exit 1
fi

if ! ( which dd &> /dev/null ); then
        echo "-E- couldn't find dd"
        exit 1
fi

dd if=/dev/urandom of=$1 bs=1M count=$2 &> /dev/null
if [ "$?" == "0" ]; then
	echo "-I $1 ($2 MB) was created"
else
	echo "-E- dd failed"
	exit 1
fi

exit 0

